package com.homework;

import java.util.Random;

public class demo03 {
    public static void main(String[] args) {
        //定义数组
        int[] arr1 = new int[5];
        int[] arr2 = new int[2];
        //获取随机数
        Random r = new Random();
        //定义2个计数器，记录arr1中偶数的的个数和对3求余为零的个数
        int count1 = 0;
        int count2 = 0;
        for (int i = 0; i < arr1.length; i++) {
            arr1[i] = r.nextInt();
            if (arr1[i] % 2 == 0) {
                count1++;
            }
            if (arr1[i] % 3 == 0) {
                count2++;
            }
        }
        //按要求保存
        arr2[0] = count1;
        arr2[1] = count2;
        //遍历arr2
        for (int a = 0; a < arr2.length; a++) {
            System.out.print(arr2[a] + " ");
        }
    }
}
